<template>
  <view>
    <view class="tabs-box">
      <view
        class="tabbar-item"
        @tap="handleRouter(item.url)"
        v-for="(item, index) in routerListFor"
        :key="index"
      >
        <view class="item-img">
          <image v-if="getRouterColor(index + 1)" :src="item.on" mode="" class="tab-icon"></image>
          <image v-else :src="item.off" mode="" class="tab-icon"></image>
        </view>
        <view class="item-text" :class="getRouterColor(index + 1) ? 'item-text-active' : ''">
          <text>{{ item.text }}</text>
        </view>
      </view>
    </view>
    <!-- <view class="h13"></view> -->
  </view>
</template>

<script>
  import { routerList, routerListFor } from './js/routerPage'
  export default {
    data() {
      return {
        router: '',
        //路由列表
        routerListFor,
      }
    },
    created() {
      uni.getSystemInfo({
        success: function (res) {
          // console.log(res)
        },
      })
    },
    methods: {
      getRouterColor(a) {
        const { route } = this.$util.getCurPage()
        return routerList[a - 1].includes(route)
      },

      handleRouter(router) {
        if ('/' + this.router === router) return false
        uni.navigateTo({
          url: router,
        })
        // uni.reLaunch({
        //     url: router
        // });
      },
    },
  }
</script>

<style lang="scss">
  .h13 {
    height: 130rpx;
  }

  .tabs-box {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-around;
    height: 130rpx;
    background-color: #fff;
    // border-top: solid 2px rgba(200,200,200,0.1);
    width: 100%;
    position: fixed;
    bottom: 0rpx;
    z-index: 99;
    .tabbar-item {
      flex: 1;
      border-top: solid 2px rgba(200, 200, 200, 0.1);
      text-align: center;
      padding-top: 15rpx;
      .item-img {
        .tab-icon {
          width: 50rpx;
          height: 50rpx;
          margin: 10rpx auto 0;
          display: block;
        }
        .release-icon {
          width: 100rpx;
          height: 100rpx;
          margin-top: -40rpx;
        }
      }
      .item-text {
        text-align: center;
        font-size: 24rpx;
        color: #888888;
      }
      .item-text-active {
        color: #096799;
      }
    }
    .center-logo2 {
      width: 80rpx;
      height: 80rpx;
      margin-top: 10rpx;
    }
    .item-release {
      position: relative;
      .item-img {
        width: 160rpx;
        height: 160rpx;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: auto;
        margin-bottom: 24rpx;
        border-radius: 50%;
        border-top: solid 2px rgba(200, 200, 200, 0.2);
        // box-shadow: 0 0 4rpx 2rpx rgba(0,0,0,0.1);
        background-color: #ffffff;
        ._center-logo {
          width: 66rpx;
          height: 65rpx;
          margin: 30rpx auto 0;
          display: block;
        }
        ._center-logo2 {
          width: 141rpx;
          height: 27rpx;
          margin: 20rpx auto 0;
          display: block;
        }
      }
    }
  }
</style>
